using System;

namespace MsPartners.Unisys.BizTalkAdapters.AdapterWizard
{
	/*
	/// <summary>
	/// Summary description for VBResourceTemplate.
	/// </summary>
	internal class VBResourceTemplate : ResourceTemplate
	{
		/// <summary>
		/// Creates handler variables code for the transmit adapter properties class
		/// </summary>
		/// <returns></returns>
		override protected string GetCodeTransmitHandlerMemberString()
		{
			string result = "";
			foreach(string name in transmitHandlerProperties)
			{
				result += "\tprivate shared " + name + " as " + 
					ConvertToVBType(transmitHandlerProperties[name]) + Environment.NewLine;
			}
			return result;
		}

		/// <summary>
		/// Creates handler extraction code for the transmit adapter properties class
		/// </summary>
		/// <returns></returns>
		override protected string GetCodeTransmitHandlerExtractString()
		{
			string result = "";
			foreach(string name in transmitHandlerProperties)
			{
				result += "\t\t" + transportType + "TransmitProperties." + 
					name + " = " + GetAppropriateExtractFunction(transmitHandlerProperties[name],name) + Environment.NewLine;
			}
			return result;
		}

		/// <summary>
		/// Creates handler properties code for the transmit adapter properties class
		/// </summary>
		/// <returns></returns>
		override protected string GetCodeTransmitHandlerPropertiesString()
		{
			string result = "";
			foreach(string name in transmitHandlerProperties)
			{
				result += 
					"\tpublic shared readonly property " + name + " as " + 
					ConvertToVBType(transmitHandlerProperties[name]) + Environment.NewLine + 
					"\tget" + Environment.NewLine +
					"\t\treturn " + name + Environment.NewLine +
					"\tend get" + Environment.NewLine + "end property" + Environment.NewLine;
			}
			return result;
		}

		/// <summary>
		/// Creates endpoint variables code for the transmit adapter properties class
		/// </summary>
		/// <returns></returns>
		override protected string GetCodeTransmitEndPointMemberString()
		{
			string result = "";
			foreach(string name in transmitEndpointProperties)
			{
				result += "\tprivate " + name + " as " + 
					ConvertToVBType(transmitEndpointProperties[name]) + Environment.NewLine;
			}
			return result;
		}

		/// <summary>
		/// Creates endpoint properties code for the transmit adapter properties class
		/// </summary>
		/// <returns></returns>
		override protected string GetCodeTransmitEndPointPropertiesString()
		{
			string result = "";
			foreach(string name in transmitEndpointProperties)
			{
				result += 
					"\tpublic readonly property " + name + " as " + 
					ConvertToVBType(transmitEndpointProperties[name]) + Environment.NewLine + 
					"\tget" + Environment.NewLine +
					"\t\treturn " + name + Environment.NewLine +
					"\tend get" + Environment.NewLine + "end property" + Environment.NewLine;
			}
			return result;
		}

		/// <summary>
		/// Creates endpoint extraction code for the transmit adapter properties class
		/// </summary>
		/// <returns></returns>
		override protected string GetCodeTransmitEndpointExtractString()
		{
			string result = "";
			foreach(string name in transmitEndpointProperties)
			{
				result += "\t\t" + transportType + "me." + 
					name + " = " + GetAppropriateExtractFunction(TransmitEndpointProperties[name],name) + Environment.NewLine;
			}
			return result;
		}

		/// <summary>
		/// Creates endpoint validation code for the designtime project
		/// </summary>
		/// <returns></returns>
		override protected string GetCodeTransmitLocationValidationString()
		{
			string result = "";
			foreach(string name in transmitEndpointProperties)
			{
				result += 
					"\t\tdim " + name + " as XmlNode  = document.SelectSingleNode(\"Config/" + name + "\")" + Environment.NewLine + 
					"\t\t' Ensure that the " + name + " supplied is not empty" + Environment.NewLine + 
					"\t\tif " + name + " is nothing Then " + Environment.NewLine + 
					"\t\t\tthrow new ApplicationException(\"Transport properties validation failed.  Value for required adapter property '" + name + "' is not specified.\")" + Environment.NewLine + 
					"\t\tEnd if" + Environment.NewLine +
					"\t\tif " + name + ".InnerText = String.Empty Then " + Environment.NewLine + 
					"\t\t\tthrow new ApplicationException(\"Transport properties validation failed.  Value for required adapter property '" + name + "' is not specified.\")" + Environment.NewLine + 
					"\t\tEnd if" + Environment.NewLine; 
			}
			return result;
		}

		/// <summary>
		/// Creates URI creation code for the designtime project
		/// </summary>
		/// <returns></returns>
		override protected string GetCodeTransmitLocationURIString()
		{
			string result = "\t\turi.InnerText = \"" + transportType + "://\"";
			foreach(string name in transmitEndpointProperties)
			{
				result += " + " + name + ".InnerText + \"/\""; 
			}
			if (transmitEndpointProperties.Length > 0)
			{
				result = result.Remove(result.Length-6,6);
			}
			return result;
		}

		/// <summary>
		/// Creates handler extraction code for the receive adapter properties class
		/// </summary>
		/// <returns></returns>
		override protected string GetCodeReceiveHandlerMemberString()
		{
			string result = "";
			foreach(string name in receiveHandlerProperties)
			{
				result += "\tprivate shared " + name + " as " +
					ConvertToVBType(receiveHandlerProperties[name]) + Environment.NewLine;
			}
			return result;
		}

		/// <summary>
		/// Creates handler extraction code for the receive adapter properties class
		/// </summary>
		/// <returns></returns>
		override protected string GetCodeReceiveHandlerExtractString()
		{
			string result = "";
			foreach(string name in receiveHandlerProperties)
			{
				result += "\t\t" + transportType + "ReceiveProperties." + 
					name + " = " + GetAppropriateExtractFunction(receiveHandlerProperties[name],name) + Environment.NewLine;
			}
			return result;
		}

		/// <summary>
		/// Creates handler properties code for the receive adapter properties class
		/// </summary>
		/// <returns></returns>
		override protected string GetCodeReceiveHandlerPropertiesString()
		{
			string result = "";
			foreach(string name in receiveHandlerProperties)
			{
				result += 
					"\tpublic shared readonly property " + name + " as " + 
					ConvertToVBType(receiveHandlerProperties[name]) + Environment.NewLine + 
					"\tget" + Environment.NewLine +
					"\t\treturn " + name + Environment.NewLine +
					"\tend get" + Environment.NewLine + "end property" + Environment.NewLine + Environment.NewLine;
			}
			return result;
		}

		/// <summary>
		/// Creates endpoint variables code for the receive adapter properties class
		/// </summary>
		/// <returns></returns>
		override protected string GetCodeReceiveEndPointMemberString()
		{
			string result = "";
			foreach(string name in receiveEndpointProperties)
			{
				result += "\tprivate " + name + " as " + 
					ConvertToVBType(receiveEndpointProperties[name]) + Environment.NewLine;
			}
			return result;
		}

		/// <summary>
		/// Creates endpoint properties code for the receive adapter properties class
		/// </summary>
		/// <returns></returns>
		override protected string GetCodeReceiveEndPointPropertiesString()
		{
			string result = "";
			foreach(string name in receiveEndpointProperties)
			{
				result += 
					"\tpublic readonly property " + name + " as " + 
					ConvertToVBType(receiveEndpointProperties[name]) + Environment.NewLine + 
					"\tget" + Environment.NewLine +
					"\t\treturn " + name + Environment.NewLine +
					"\tend get" + Environment.NewLine + "end property" + Environment.NewLine + Environment.NewLine;
			}
			return result;
		}

		/// <summary>
		/// Creates endpoint extraction code for the receive adapter properties class
		/// </summary>
		/// <returns></returns>
		override protected string GetCodeReceiveEndpointExtractString()
		{
			string result = "";
			foreach(string name in receiveEndpointProperties)
			{
				result += "\t\t" + transportType + "me." + 
					name + " = " + GetAppropriateExtractFunction(receiveEndpointProperties[name],name) + Environment.NewLine;
			}
			return result;
		}

		/// <summary>
		/// Creates endpoint validation code for the designtime project
		/// </summary>
		/// <returns></returns>
		override protected string GetCodeReceiveLocationValidationString()
		{
			string result = "";
			foreach(string name in receiveEndpointProperties)
			{
				result += 
					"\t\tdim " + name + " as XmlNode  = document.SelectSingleNode(\"Config/" + name + "\")" + Environment.NewLine + 
					"\t\t' Ensure that the " + name + " supplied is not empty" + Environment.NewLine + 
					"\t\tif " + name + " is nothing Then " + Environment.NewLine + 
					"\t\t\tthrow new ApplicationException(\"Transport properties validation failed.  Value for required adapter property '" + name + "' is not specified.\")" + Environment.NewLine + 
					"\t\tEnd if" + Environment.NewLine +
					"\t\tif " + name + ".InnerText = String.Empty Then " + Environment.NewLine + 
					"\t\t\tthrow new ApplicationException(\"Transport properties validation failed.  Value for required adapter property '" + name + "' is not specified.\")" + Environment.NewLine + 
					"\t\tEnd if" + Environment.NewLine; 
			}
			return result;
		}

		/// <summary>
		/// Creates endpoint URI code for the designtime project
		/// </summary>
		/// <returns></returns>
		override protected string GetCodeReceiveLocationURIString()
		{
			string result = "\t\turi.InnerText = \"" + transportType + "://\"";
			foreach(string name in receiveEndpointProperties)
			{
				result += " + " + name + ".InnerText + \"/\""; 
			}
			if (receiveEndpointProperties.Length > 0)
			{
				result = result.Remove(result.Length-6,6);
			}
			return result;
		}
	
		/// <summary>
		/// Converts an xsd datatype to a VB datatype
		/// </summary>
		/// <param name="dataType"></param>
		/// <returns></returns>
		protected string ConvertToVBType(string dataType)
		{
			switch(dataType)
			{
				case "xs:string":
					return "string";
				case "xs:boolean":
					return "boolean";
				case "xs:int":
					return "integer";
				case "xs:long":
					return "long";
				default:
					return "string";
			}
		}
	}
	 */
}
